home *** CD-ROM | disk | FTP | other *** search
- /*
- * ODBCdataTranslate.c
- *
- * (c) Apple Computer, Inc 1993
- * (c) Visigenic Software, Inc 1995
- *
- * changes:
- *
- * 1.0a1 - removed all calls to OpenGlobalWorld, as this is compiled model far
- * and doesn't have any A5-relative references to globals. Also
- * removed code to set up the QuickDraw environment, e.g. calls to
- * InitGraf, etc., as these should not be done more than once from a process.
- * A5 world is assumed to have valid QD globals when this shared library is called.
- */
-
- #include <Dialogs.h>
- #include <Fonts.h>
- #if ! PPCODBC
- #include <LibraryManagerUtilities.h>
- #endif // ! PPCODBC
- #include <Menus.h>
- #include <OSUtils.h>
- #include <QuickDraw.h>
- #include <TextEdit.h>
- #include <Windows.h>
-
- #include "ODBCSharedLibraries.h"
- #include "DataTran.h"
-
- #include "ConfigTranslator.h"
-
- /*
- * Prototypes
- */
-
- /*
- * Public functions
- */
-
- #if PPCODBC
-
- #include <Memory.h>
- #include <Errors.h>
-
- Handle hinst;
-
- // _____________________________________________________________________________
- OSErr
- SampleTranslateInit( InitBlockPtr ib )
- {
- /*
- * shared library init function. All shared libraries should have one. Its name is
- * declared in the .exp file.
- */
-
- if ( ib->fragLocator.where != kOnDiskFlat ) { return -32323; }
-
- hinst = NewHandle( sizeof( ODBCLibConnection ) );
- if ( ! hinst ) { return memFullErr; }
- HLock( hinst );
-
- (*(ODBCLibConnection**)hinst)->spec = *ib->fragLocator.u.onDisk.fileSpec;
- (*(ODBCLibConnection**)hinst)->connId = ib->connectionID;
-
- HUnlock( hinst );
- }
-
-
- // _____________________________________________________________________________
- extern "C"
- void
- SampleTranslateMain( HINSTANCE hinst2init )
- {
- HLock( hinst );
- HLock( hinst2init );
- **(ODBCLibConnection**)hinst2init = **(ODBCLibConnection**)hinst;
- HUnlock( hinst );
- HUnlock( hinst2init );
- }
-
-
- #else // PPCODBC
-
- // _____________________________________________________________________________
- void
- SampleTranslateInit()
- {
- /*
- * shared library init function. All shared libraries should have one. Its name is
- * declared in the .exp file.
- */
-
- // note: hinst is not needed for the 68k ODBCSharedLibraries functions
- }
-
- #endif // PPCODBC
-
- // _____________________________________________________________________________
- void
- SampleTranslateObit()
- {
- /*
- * Shared library cleanup function. All shared libraries should have one. Its name is
- * declared in the .exp file.
- */
-
- #if PPCODBC
- DisposHandle( hinst );
- #endif // PPCODBC
- }
-
- TRANSPREAPI BOOL TRANSAPI
- ConfigTranslator(GrafPtr pGrafPort, /* window to center over */
- DWORD *pvOption) /* translation option */
- {
- /*
- * Shared lilbrary entry point for configuring a data translator.
- */
-
- BOOL success;
- ODBCLibResContext context;
-
- if ( ODBCLibUseLocalRes( &context ) )
- {
- SysBeep(1); // can't put up our alert if ODBCLibUseLocalRes failed
- return FALSE;
- }
-
- /*
- * do the work
- */
-
- success = (BOOL) DoConfigTranslator((WindowPtr) pGrafPort, pvOption);
-
- /*
- * restore resource path, A5 world
- */
-
- ODBCLibCloseLocalRes( &context );
-
- return success;
- }
-
- TRANSPREAPI BOOL TRANSAPI
- SQLDataSourceToDriver(UDWORD fOption,
- SWORD fCType,
- PTR rgbValueIn,
- SDWORD cbValueIn,
- PTR rgbValueOut,
- SDWORD cbValueOutMax,
- SDWORD *pcbValueOut,
- UCHAR *szErrorMsg,
- SWORD cbErrorMsgMax,
- SWORD *pcbErrorMsg)
- {
- #pragma unused( fOption, fCType, rgbValueIn, cbValueIn, rgbValueOut, cbValueOutMax, pcbValueOut, szErrorMsg, cbErrorMsgMax, pcbErrorMsg )
- /*
- * Shared lilbrary entry point for SQLDataSourceToDriver.
- */
-
- BOOL success;
- ODBCLibResContext context;
-
- if ( ODBCLibUseLocalRes( &context ) )
- {
- SysBeep(1); // can't put up our alert if ODBCLibUseLocalRes failed
- return FALSE;
- }
-
- /*
- * here's where the work gets done
- */
-
- success = TRUE; // your code goes here
-
- /*
- * restore resource path, A5 world
- */
-
- ODBCLibCloseLocalRes( &context );
-
- return success;
- }
-
- TRANSPREAPI BOOL TRANSAPI
- SQLDriverToDataSource(UDWORD fOption,
- SWORD fCType,
- PTR rgbValueIn,
- SDWORD cbValueIn,
- PTR rgbValueOut,
- SDWORD cbValueOutMax,
- SDWORD *pcbValueOut,
- UCHAR *szErrorMsg,
- SWORD cbErrorMsgMax,
- SWORD *pcbErrorMsg)
- {
- #pragma unused( fOption, fCType, rgbValueIn, cbValueIn, rgbValueOut, cbValueOutMax, pcbValueOut, szErrorMsg, cbErrorMsgMax, pcbErrorMsg )
- /*
- * Shared lilbrary entry point for SQLDriverToDataSource.
- */
-
- BOOL success;
- ODBCLibResContext context;
-
- if ( ODBCLibUseLocalRes( &context ) )
- {
- SysBeep(1); // can't put up our alert if ODBCLibUseLocalRes failed
- return FALSE;
- }
-
- /*
- * here's where the work gets done
- */
-
- success = TRUE; // your code goes here
-
- /*
- * restore resource path, A5 world
- */
-
- ODBCLibCloseLocalRes( &context );
-
- return success;
- }
-
-